﻿using DevExpress.XtraReports.UI;
using DevTeam;

namespace ConfExpert.Forms.Rapor
{
    public partial class xrDU4KesimFoyu : DevExpress.XtraReports.UI.XtraReport
    {
        public xrDU4KesimFoyu()
        {
            InitializeComponent();
        }
        public xrDU4KesimFoyu(string idx)
            : this()
        {
            myData1.Merge(Session.DataManager.ExecuteDataSet("CreateKesimFoyu", idx));
            myData1.xDU4Master.Merge(myData1.Tables["Table"]);
            myData1.xDU4Foys.Merge(myData1.Tables["Table1"]);
            myData1.Du4KesimNo.Merge(myData1.Tables["Table2"]);
        }

        private void xrDU4KesimFoyu_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            for (int i = 32; i < 51; i++)
            {
                if (i == 33)
                    continue;
                if (myData1.xDU4Foys.Select("ISNULL([" + i.ToString() + "],0)<>0").Length == 0)
                {
                    ((XRTableCell)this.FindControl("header" + i.ToString(), false)).Dispose();
                    ((XRTableCell)this.FindControl("beden" + i.ToString(), false)).Dispose();
                    ((XRTableCell)this.FindControl("footer" + i.ToString(), false)).Dispose();
                }
                else break;
            }
            if (myData1.xDU4Foys.Select("ISNULL(ST,0)<>0").Length == 0)
            {
                headerSt.Dispose();
                detailSt.Dispose();
                footerSt.Dispose();

                for (int i = 50; i > 31; i--)
                {
                    if (i == 33)
                        continue;
                    if (myData1.xDU4Foys.Select("ISNULL([" + i.ToString() + "],0)<>0").Length == 0)
                    {
                        ((XRTableCell)this.FindControl("header" + i.ToString(), false)).Dispose();
                        ((XRTableCell)this.FindControl("beden" + i.ToString(), false)).Dispose();
                        ((XRTableCell)this.FindControl("footer" + i.ToString(), false)).Dispose();
                    }
                    else break;
                }
            }
            if (myData1.xDU4Foys.Select("ISNULL(Fit,'')<>''").Length == 0)
            {
                headerFit.Dispose();
                detailFit.Dispose();
                footerFit.Dispose();
            }
            if (myData1.xDU4Foys.Select("ISNULL(Contrast3,'')<>''").Length == 0)
            {
                headerContrast3.Dispose();
                detailContrast3.Dispose();
                footerContrast3.Dispose();
            }
            if (myData1.xDU4Foys.Select("ISNULL(Contrast2,'')<>''").Length == 0)
            {
                headerContrast2.Dispose();
                detailContrast2.Dispose();
                footerContrast2.Dispose();
            }
            if (myData1.xDU4Foys.Select("ISNULL(Contrast,'')<>''").Length == 0)
            {
                headerContrast.Dispose();
                detailContrast.Dispose();
                footerContrast.Dispose();
            }
            if (myData1.xDU4Foys.Select("ISNULL(Iplik,'')<>''").Length == 0)
            {
                headerOrjArticle.Dispose();
                detailOrjArticle.Dispose();
                footerOrjArticle.Dispose();
            }
            if (myData1.xDU4Foys.Select("ISNULL(Commetion,'')<>''").Length == 0)
            {
                headerCommetion.Dispose();
                detailCommetion.Dispose();
                footerCommetion.Dispose();
            }
            if (myData1.xDU4Foys.Select("ISNULL(OverDeyd,'')<>''").Length == 0)
            {
                headerOver.Dispose();
                detailOver.Dispose();
                footerOver.Dispose();
            }
            if (myData1.xDU4Foys.Select("ISNULL(Barkod,'') like '%YES%'").Length == 0)
            {
                headerBarcode.Dispose();
                detailBarcode.Dispose();
                footerBarcode.Dispose();
            }
            xrPictureBox1.WidthF = detailKumas.WidthF;
        }

        private void xrTableCell34_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            xrTable7.WidthF = this.xrTableCell34.WidthF;
        }

        private void detailContrast_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            xrTable8.WidthF = this.detailContrast.WidthF;
        }

        private void detailContrast2_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            xrTable9.WidthF = this.detailContrast2.WidthF;
        }

        private void detailContrast3_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            xrTable11.WidthF = this.detailContrast3.WidthF;
        }

    }
}
